package com.zzptc.zcg.exam;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.Timer;
import java.util.TimerTask;

public class MainActivity extends AppCompatActivity {

    ImageView   iv;
    TextView    tv;
    private boolean flag_login = true;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        iv = (ImageView) findViewById(R.id.iv_login);
        tv = (TextView) findViewById(R.id.tv_login);
        SharedPreferences s = getSharedPre();
        boolean b = s.getBoolean("exam",false);
        if (b){
            startActivity(new Intent(this,LoginActivity.class));
        }else {
            final Intent it = new Intent(this, Main2Activity.class); //你要转向的Activity
            Timer timer = new Timer();
            TimerTask task = new TimerTask() {
                @Override
                public void run() {
                    startActivity(it); //执行
                    finish();
                }
            };
            timer.schedule(task, 1000);
        }

        finish();
    }

    public SharedPreferences getSharedPre(){
        return  getSharedPreferences("exam", Context.MODE_PRIVATE);
    }

}
